#ifndef _CLASS_H_
#define _CLASS_H_

#include "CType.h"

typedef void (*init_object_callback)(void*);
typedef void (*init_class_callback)(void*);

typedef struct _CObject			CObject;
typedef struct _CObjectClass	CObjectClass;
typedef struct _ClassInfo		ClassInfo;
typedef struct _ClassType		ClassType;

struct _CObject
{
	CObjectClass *vclass;
	u32	ref_counter;
};

struct _CObjectClass
{
	u32	 class_type;
    void (*destroy)(CObject *object);		//virtual destructor
};

struct _ClassInfo
{
	char 	*name;
	s32     object_size;
	s32     class_size;
	void (*init_object)(void*);
	void (*init_class)(void *);
};

struct _ClassType
{
	char	*name;
	s32     class_size;
	s32     object_size;
	CObjectClass*  vclass;
	void (*init_class)(void*);
	void (*init_object)(void*);
	ClassType* parent;
	ClassType* next;
};


u32 get_cobject_type(void);

CObject* cobject_new(void);

void cobject_destroy(CObject *object);

void init_object_list(void);

void init_parent_object(ClassType *current, void *object);

u32 register_class_type(ClassInfo *classinfo, u32 parent_type);

void* g_object_new(u32 class_type);

CObject* g_type_check_instance_cast(CObject *obj, u32 classtype);

CObjectClass* g_type_check_class_cast(CObjectClass *vclass, u32 classtype);

CObjectClass* g_type_get_instance_class(CObject *obj, u32 classtype);

CObjectClass* g_type_class_peek_parent(CObjectClass* vclass);


#endif //_CLASS_H_